module.exports = {
  apps: [{
    name: 'dx-fun-group-backend',
    script: './apps/backend/dist/app.js',
    cwd: '/var/www/dx-fun-group',
    instances: 1,
    autorestart: true,
    watch: false,
    max_memory_restart: '512M',
    env: {
      NODE_ENV: 'production',
      PORT: 3000
    },
    env_production: {
      NODE_ENV: 'production',
      PORT: 3000
    },
    log_file: './logs/combined.log',
    out_file: './logs/out.log',
    error_file: './logs/error.log',
    log_date_format: 'YYYY-MM-DD HH:mm Z',
    merge_logs: true,
    time: true
  }],

  deploy: {
    production: {
      user: 'deploy',
      host: 'your-server-ip',
      ref: 'origin/main',
      repo: 'git@github.com:your-username/dx-fun-group.git',
      path: '/var/www/dx-fun-group',
      'pre-deploy-local': '',
      'post-deploy': 'pnpm install && pnpm build:shared && pnpm build:frontend && pnpm build:backend && pm2 reload ecosystem.config.js --env production',
      'pre-setup': ''
    }
  }
};
